@using BlazorApp.Pages.Common.Html
@using BlazorApp.Pages.Common.Html.HTable
@using BlazorApp.Pages.Common.Metadata
@using k8s.Models
@inherits BlazorApp.Pages.Common.PageBase
@if (Rules is { Count: > 0 })
{
    <HTableColumn Title=@L["Rules"] ExplainField=@(ExplainFieldPrefix + ".rules")>
        @foreach (var rule in Rules)
        {
            <HTable>
                <PropertyListView Items="@rule.ApiGroups" T="string" Title=@L["ApiGroups"]
                                  ExplainField=@(ExplainFieldPrefix + ".rules.apiGroups")>
                </PropertyListView>
                <PropertyListView Items="@rule.ApiVersions" T="string" Title=@L["ApiVersions"]
                                  ExplainField=@(ExplainFieldPrefix + ".rules.verbs")>
                </PropertyListView>
                <PropertyListView Items="@rule.Resources" T="string" Title=@L["Resources"]
                                  ExplainField=@(ExplainFieldPrefix + ".rules.resources")>
                </PropertyListView>
                <PropertyListView Title=@L["Operations"] T="string" Items="@rule.Operations"
                                  ExplainField=@(ExplainFieldPrefix + ".rules.operations")>
                </PropertyListView>
                <PropertySimpleView Title=@L["Scope"] Item="@rule.Scope"
                                    ExplainField=@(ExplainFieldPrefix + ".rules.scope")>
                </PropertySimpleView>
            </HTable>
        }
    </HTableColumn>
}

@code {

    [Parameter] public IList<V1RuleWithOperations> Rules { get; set; }

    [Parameter] public string ExplainFieldPrefix { get; set; }

}
